package enums;

public enum ResCodeEnum {
	SUCCESS(0, "成功"), 
	SUCCESS_OK(1, "成功"), 
	FAIL(-1, "失败"),
	NO_ACCESS_TOKEN(10000, "缺少accessToken参数"),
	UG_ACCESS_TOKEN(10001, "accessToken无效"),
	OVER_ACCESS_TOKEN(10002, "accessToken已过期，请重新获取"),
	UG_PAEAMES(10003,"缺少必要参数或参数不合法"),
	UG_APPID(10004,"不合法的appid"),
	UG_SECRET(10005,"不合法的secret"),
	UG_MEMBER(10006,"不合法的用户"),
	UG_OPENID(10007,"不合法的openid"),
	INSUFFICIENT(10008,"条件不足"),
	US_NULL(10009,"该用户不存在"),
	US_EXPR(10010,"该系统用户过期"),
	US_LOCK(10011,"该系统用户已锁定"),
	NULL_REPONSE(10012,"返回值为空"),
	NO_DATA(10013,"没数据"),
	USE_COUPON_FAIL(10014,"优惠券核销失败"),
	US_FALSE_PWD(10015,"用户密码输入错误"),
	CODE_REPEAT(10016,"单号重复"),
	CUSTOM(10017,"自定义"),
	DATA_ERROR(10018,"数据库操作失败"),
	CUR_VERSION_NEW(20000,"当前是最新版本"),
	NEW_VERSION_AVA(20001,"发现新版本"),
    APPLICATION_FAIL(20002,"请勿重复提交"),
    SHOPPINGKILL_OVER(2004,"秒杀商品已下架"),
    SHOPPINGKILL_FINISH(2005,"秒杀商品已抢完"),
    SHOPPINGKILL_ERROR(2006,"秒杀商品暂未开抢或已过期或已下架"),
    INTEGRAL_DEFICIENCY(2007,"用户积分不足"),
	SHOPPINGKILL_COUNT(2009,"用户秒杀次数不足"),
    STOREID_NOT(20003,"没有选择商户"),
	UN_REGISTERED(20004,"未查询到数据")

	;
	private Integer code;
	private String msg;

	private ResCodeEnum(Integer code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public Integer getCode() {
		return code;
	}

	public void setCode(Integer code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public static String getMsgByCode(Integer code) {
		String msg = "";
		ResCodeEnum[] array = ResCodeEnum.values();
		for (ResCodeEnum obj : array) {
			if (code.equals(obj.code)) {
				msg = obj.msg;
				break;
			}
		}
		return msg;
	}
}
